#include "TankState.h"

TankState::TankState(int posX, int posY, string playerName, string nameObj) : SceneObjectState(nameObj) 
{
	this->kPressedM = false;
	this->kPressedR = false;
	setAngle(0);
	setShot(false);
	setSpeed(0);
	setAngularSpd(0);
	rotation = false;
}

TankState::~TankState(void)
{
}

void TankState::setAngle(int angle)
{
	this->angle = angle;
}
//------------------------------------------------------------------------------
int TankState::getAngle()
{
	return this->angle;
}
//------------------------------------------------------------------------------
void TankState::setShot(bool flag)
{
	this->shot = false;
}
//------------------------------------------------------------------------------
bool TankState::getShot(){
	return this->shot;
}
//------------------------------------------------------------------------------
void TankState::setAngularSpd(int angSpd)
{
	this->angularSpd = angSpd;
}
//------------------------------------------------------------------------------
int TankState::getAngularSpd(){
	return this->angularSpd;
}
//------------------------------------------------------------------------------
void TankState::setSpeed(int speed)
{
	this->speed = speed;
}
//------------------------------------------------------------------------------
int TankState::getSpeed(){
	return this->speed;
}
//------------------------------------------------------------------------------
void TankState::setRotation(bool flag)
{
	this->rotation = speed;
}
//------------------------------------------------------------------------------
bool TankState::getRotation(){
	return this->rotation;
}
//------------------------------------------------------------------------------
void TankState::rotate()
{
	/*this->angle += angularSpd;
	this->angle = angle % 360;
	if( this->angularSpd < 0){
		if (this->surfaces_it == this->rotSurfaces->begin()){
			LISTSUR::iterator end = this->rotSurfaces->end();
			end--;
			this->surfaces_it = end;
		} else 
			this->surfaces_it--;
	}else
		if (this->angularSpd > 0){
			LISTSUR::iterator end = this->rotSurfaces->end();
			end--;
			if (this->surfaces_it == end){			
				this->surfaces_it = this->rotSurfaces->begin();
			} else 
				this->surfaces_it++;
		}
	
	this->tmp = *this->surfaces_it;
	rotation=true;*/
}
//------------------------------------------------------------------------------
void TankState::move(SceneState* s)
{/*
	int x = this->getX();
	int y = this->getY();

	int incx = (int)(getSpeed() * sinf((float)(getAngle() * M_PI / 180)));
	int incy = (int)(getSpeed() * cosf((float)(getAngle() * M_PI / 180)));

	y += incy;
	x += incx;
	if (s->ocurredInside(x + getWidth() / 2, y + getHeight() / 2) && s->ocurredInside(x - getWidth() / 2, y - getHeight() / 2))
	{
		setXCoordinate(x);
		setYCoordinate(y);
	}*/
}

void TankState::retreat()
{
	/*int x = this->getXCoordinate();
	int y = this->getYCoordinate();
	y -= speed * cosf(angle*M_PI/180);
	x -= speed * sinf(angle*M_PI/180);
	this->setPosition(x, y);*/
}

